#ifndef DETECTORNC_H
#define DETECTORNC_H

#include <zxing/common/Counted.h>
#include <zxing/common/DetectorResult.h>
#include <newcode/ByteMatrix.h>
#include <newcode/GreyscaleDetectorResult.h>
#include <zxing/LuminanceSource.h>
#include <zxing/datamatrix/detector/DetectorDM.h>

namespace newcode{
namespace detector{

using namespace zxing;

class Detector: public datamatrix::Detector
{
private:
    Ref<ByteMatrix> image_;
    unsigned char *dataBuffer;

    Ref<BitMatrix> binarize(Ref<ByteMatrix> matrix);
    inline static int round(float a);

protected:
    Ref<ByteMatrix> sampleGrid(Ref<ByteMatrix> image, int dimension,
        Ref<PerspectiveTransform> transform);

    static void correctContrast(Ref<ByteMatrix> image);

public:
    Detector(Ref<ByteMatrix> image);
    virtual ~Detector();
    Ref<GrayscaleDetectorResult> detect();
    Ref<ByteMatrix> getImage() const;
};

}
}

#endif // DETECTORNC_H
